// ml278
// Copyright (C) 2008 Bjørn Øivind Bjørnsen, Aleksander Gjermundsen, Knut Andre Tidemann, Thomas Hansen
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#ifndef __KEYBINDINGSMANAGER_H
#define __KEYBINDINGSMANAGER_H

#include "Ogre.h"
#include <vector>
#include <OIS/OIS.h>
#include <string>

using namespace Ogre;

namespace ml278
{
	/** Constants used for identifying keybindings */
        enum KeyBindings 
        {
                KEY_FORWARD, 
                KEY_BACKWARD, 
                KEY_YAW_LEFT, 
                KEY_YAW_RIGHT, 
                KEY_PITCH_UP, 
                KEY_PITCH_DOWN, 
                KEY_SCREENSHOT, 
                KEY_KEYS_OVERLAY, 
                KEY_STATS_OVERLAY, 
                KEY_SWITCH_TEXTURE_FILTERING, 
                KEY_SWITCH_POLYGON_MODE, 
                KEY_CAMERA_FIRST_PERSON, 
                KEY_CAMERA_THIRD_PERSON,
		KEY_CAMERA_FREEROAM,
                KEY_TOGGLE_GUI,
                KEY_QUIT
        };

}

/**
 * Class to store and restore keybindings.
 * Holds a set of keys which can be used elsewhere.
*/
class KeyBindingsManager
{
	protected:
                String mFilename;				/**< filename used to store the configuration */
	public:
                static const unsigned int NUM_BINDED_KEYS = 16;	/**< number of keys handled, change when adding/removing bindings from enum */

                OIS::KeyCode keys[NUM_BINDED_KEYS];		/**< the keybindings - keycodes corresponding to the constants */
                OIS::KeyCode defaultKeys[NUM_BINDED_KEYS];	/**< default keybindings */
                std::string keyNames[NUM_BINDED_KEYS];		/**< names of the constants in the KeyBindings-enum */
                std::string keyBindingNames[NUM_BINDED_KEYS];	/**< descriptive names of the keybindings */

                KeyBindingsManager(const String &filename);
                bool initKeys();
                bool saveDefaultKeys();
                std::vector<OIS::KeyCode> getDefaultKeys();
                bool saveAllKeys(const std::vector<OIS::KeyCode>*);
                void setTempAllKeys(const std::vector<OIS::KeyCode>*);
                OIS::KeyCode getKey(ml278::KeyBindings);
                std::string getKeyCodeString(OIS::KeyCode);
		std::string getKeyCodeName(ml278::KeyBindings);

                int getNumBindings();

		~KeyBindingsManager();

		};

#endif // #ifndef __KEYBINDINGSMANAGER_H
